sharepoint  2010event recivers

hi ,

      i have simple scenario with me.can u help me any one....

i have the "employee" custom list in my site...so i decided to restrict the delete the items in that list.so i know that we need to give "propperties.cancel=true"..this is working i know.but my question is 

' i want restrict to delete the items on a particular employee list..means any thing i want fire the event receivers in my specific list.not based on my template id..is it possible,,if possible.suggest me how..i know its a basic qes.but i am new to development..

Thanking you in advance.

July 17th, 2013 2:04pm

Create  content type called employees and it to your list. then your event listener can operate only on the content type. If you cant scope your event receiver to web and check for the list name to employees.

  public override void ItemDeleting(SPItemEventProperties properties)
       {
           base.ItemDeleting(properties);
           if (properties.List.Title == "Employees")
               properties.Cancel = true;

       }


Free Windows Admin Tool Kit Click here and download it now
July 17th, 2013 2:52pm

Hello,

If you just want to restrict delete item then you can try with custom permission level. (No code is required). Go to site action-->site permission-->permission level-->add permission level-->and select appropriate permission except "Delete Items".

Now you can assign this permission to any user/group at list level so they can add/edit item but not delete.

For event receiver, you need to change feature.xml file to fire event for specific list:

http://msdn.microsoft.com/en-us/library/ff398052.aspx

Hope it could help

July 18th, 2013 3:27am

Hi,

 In the Elements.xml file, change

<Receivers ListTemplateId="100"> to <Receivers ListUrl="Lists/employee">

Free Windows Admin Tool Kit Click here and download it now
July 18th, 2013 5:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics